package com.atguigu.mybatis.mapper;

import com.atguigu.mybatis.bean.Employee;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Created by Smexy on 2022/10/10
 *
 *      有些公司的sql需要经常升级维护，选择在配置文件xml中编写sql
 *      有的公司的sql可能不维护(一锤子买卖)，为了开发效率(写的快)，选择使用注解将sql写在方法上。
 *
 *        是什么sql，就用什么注解
 */
public interface EmployeeAnotherMapper
{

    //crud
    @Select("select * from employee where id = #{a}")
    Employee getEmployeeById(@Param("a")Integer id);


    @Select("select * from employee where id = #{a}")
    Employee getEmployeeById3(@Param("a") Integer id,String a);

    /*
            @Param("xxxx")自定义  占位符的属性名
     */
    @Select("select * from employee where id = #{xxxx}")
    Employee getEmployeeById2(@Param("xxxx") Integer id);

    @Select("select * from ${t} where last_name = '${xxxx}'")
    Employee getEmployeeById4(@Param("xxxx") String name,@Param("t")String t);

}
